package com.example.chinesenation.Service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.chinesenation.Entity.Attention;
import com.example.chinesenation.Entity.Collect;
import com.example.chinesenation.Mapper.AttentionMapper;
import com.example.chinesenation.Service.IAttentionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sakuraFallingDown
 * @since 2021-01-12
 */
@Service
public class AttentionServiceImpl extends ServiceImpl<AttentionMapper, Attention> implements IAttentionService {
    @Override
    public int countByUid(String uid) {
        QueryWrapper<Attention> qw=new QueryWrapper<>();
        qw.eq("uid",uid);
        return count(qw);
    }

    @Override
    public IPage<Attention> getByUid(String uid, int current, int size) {
        QueryWrapper<Attention> qw=new QueryWrapper<>();
        IPage<Attention> iPage=new Page<>(current,size);
        qw.eq("uid",uid);
        qw.orderByDesc("create_time");
        return page(iPage,qw);
    }
}
